package org.shilong;

import org.shilong.UI.R;
import org.shilong.UI.WeiboTest;
import org.shilong.Utility.constants.APIConstants;
import org.shilong.Utility.constants.WeiboConstants;

import android.app.Activity;
import android.os.Bundle;

import com.weibo.net.AccessToken;
import com.weibo.net.Oauth2AccessTokenHeader;
import com.weibo.net.Utility;
import com.weibo.net.Weibo;
import com.weibo.net.WeiboException;
import com.weibo.net.WeiboParameters;

public class WTest extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView( R.layout.weibo_test );


		initlize();

		try {
			getUID();
		} catch (WeiboException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	private void initlize(){



	}

	private void getUID() throws WeiboException{

		
		Weibo.getInstance().setupConsumerConfig( WeiboConstants.APIKEY, WeiboConstants.APISECRET );
		Weibo.getInstance().setRedirectUrl( WeiboConstants.CALLBACK_URL );
			
		
		
		AccessToken accessToken = new AccessToken("2.00DCkNxC8Y8jHB574970c0c12qB4uD", WeiboConstants.APISECRET);
		accessToken.setExpiresIn("86399");
		
		Weibo.getInstance().setAccessToken( accessToken );


		System.out.println( "APIKEY:" + Weibo.getAppKey());

		Weibo mWeibo = Weibo.getInstance();
		
		WeiboParameters params = new WeiboParameters();

		params.add("source", WeiboConstants.APIKEY);
		params.add("uid", "2707344703");
		
		Utility.setAuthorization(new Oauth2AccessTokenHeader());  //	加上之后就不报出现过期的等异常了
		
		String rlt = "";

		rlt = mWeibo
				.request(WTest.this, APIConstants.GET_FRIEND,
						params, Utility.HTTPMETHOD_GET,
						mWeibo.getAccessToken());

		System.out.println( "rlt:" + rlt );

	}


}
